package jp.tkym.labs.rpc;

import java.io.Serializable;
import java.lang.reflect.Method;

class RpcBean implements Serializable{
	/**  */
	private static final long serialVersionUID = 6711220447379629681L;
	private final String methodName;
	private final String[] parameterTypes;
	private Object result;
	private Object[] parameters;
	private Exception exception;
	
	RpcBean(String methodName, String... parameterTypes){
		this.methodName = methodName;
		this.parameterTypes = parameterTypes;
	};
	
	RpcBean(Method method){
		this(method.getName(), namesFromClass(method.getParameterTypes()));
	}
	
	static String[] namesFromClass(Class<?>... classes){
		String[] arrays = new String[classes.length];
		for(int i=0; i<classes.length; i++) 
			arrays[i] = classes[i].getName();
		return arrays;
	}
	
	public String getMethodName() {
		return methodName;
	}

	public String[] getParameterTypes() {
		return parameterTypes;
	}

	public Object getResult() {
		return result;
	}
	
	public void setResult(Object result) {
		this.result = result;
	}
	public Object[] getParameters() {
		return parameters;
	}
	public void setParameters(Object... parameters) {
		this.parameters = parameters;
	}
	public Exception getException() {
		return exception;
	}
	public void setException(Exception exception) {
		this.exception = exception;
	}
}